package com.soft.dao;

import com.soft.entity.Admin;
import com.soft.entity.UserInfo;
import com.soft.util.Connect;

import java.util.ArrayList;
import java.util.List;

public class AdminDao {

    Class<Admin> adminClass;

    public AdminDao() {
        adminClass = (Class<Admin>) Admin.class;
    }

    public Admin get(String account) {
        List<Object> list = new ArrayList<Object>();
        list.add(account);
        String sql = "select * from admin where id = ?";
        Admin admin = Connect.getInstance().queryObject(sql,list,adminClass);
        return admin;
    }

    public boolean AdminLogin(String account, String pwd) {
        List<Object> list = new ArrayList<Object>();
        list.add(account);
        list.add(pwd);
        String sql = "select * from admin where id = ? and password = ?";
        Admin admin = Connect.getInstance().queryObject(sql,list,adminClass);
        if(admin != null)
            return true;
        return false;
    }
}
